#!/bin/bash

# Docker构建代理配置脚本
# 使用方法: ./build-with-proxy.sh [代理地址] [代理端口] [镜像标签]

# 默认配置
PROXY_HOST=${1:-"proxy.example.com"}
PROXY_PORT=${2:-"8080"}
IMAGE_TAG=${3:-"docker-ssh:latest"}

# 代理URL
HTTP_PROXY_URL="http://${PROXY_HOST}:${PROXY_PORT}"
HTTPS_PROXY_URL="http://${PROXY_HOST}:${PROXY_PORT}"

echo "使用代理构建Docker镜像..."
echo "代理地址: ${HTTP_PROXY_URL}"
echo "镜像标签: ${IMAGE_TAG}"
echo ""

# 构建命令
docker build \
  --build-arg HTTP_PROXY=${HTTP_PROXY_URL} \
  --build-arg HTTPS_PROXY=${HTTPS_PROXY_URL} \
  --build-arg NO_PROXY=localhost,127.0.0.1 \
  -t ${IMAGE_TAG} -f docker-ssh.Dockerfile .

echo ""
echo "构建完成！"
